package com.wise.site.protocol.result;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONObject;

import android.content.Context;

import com.wise.site.protocol.base.SoapResult;
import com.wise.site.utils.Constanct;

/**
 * 动态的模块数据容器
 * @author huangyue
 *
 * 2012-9-17
 */
public class ModelResult extends SoapResult{
	private String logoURI;
	private HashMap<Integer, TabItem> tabs;
	public AboutUSResult aboutUS;
	

	@Override
	public void parseData(String response) throws Exception {
		JSONObject json = new JSONObject(response);
		
		if(json.getInt("flag") == 1){
			json = new JSONObject(json.getString("msg"));
//			logoURI = json.getString("logoURI");
			tabs = new HashMap<Integer, TabItem>();
			if(!json.isNull("news")){
				tabs.put(1, new TabItem(json.getJSONObject("news")));
			}
			if(!json.isNull("supply_demand")){
				tabs.put(2, new TabItem(json.getJSONObject("supply_demand")));
			}
			if(!json.isNull("shop")){
				tabs.put(3, new TabItem(json.getJSONObject("shop")));
			}
			if(!json.isNull("user")){
				tabs.put(4, new TabItem(json.getJSONObject("user")));
			}
			if(!json.isNull("more")){
				tabs.put(5, new TabItem(json.getJSONObject("more")));
			}
			if(!json.isNull("aboutus")){
				aboutUS = new AboutUSResult(json.getJSONObject("aboutus"));
			}
		}
		
	}
	
	
	public int getTabCount(){
		if(tabs == null){
			return 0;
		}
		return tabs.size();
	}
	
	/**
	 * 输入需要获取的tab id，id由1开始
	 *
	 * huangyue  2012-9-27
	 */
	public TabItem getTabItem(int tabType){
		return tabs.get(tabType);
	}
	
	public String getLogoURI() {
		return logoURI;
	}


}
